<div class="form_container">
    {% if TheAssignment %}
	    <h1>
		<a class="management_option button DeleteButton floatright" href="{% course_url management app='grades' command='delete' arguments=TheAssignment.category_slug|add:"&"|add:TheAssignment.title_slug %}" title="Delete this assignment">X</a>
		Edit Assignment
	    </h1>
    {% else %}<h1>Create Assignment</h1>
    {% endif %}
<div class="clear"></div>
    <form action='.' method='post'>{% csrf_token %}
	<button type="submit" class="button SaveButton" name="Save" value="SaveEdit" style="position: fixed; bottom: 0px; right: 0px; z-index: 5;" title="Save and Continue Editing">Save</button>

	<table>{{Form.as_table}}{% if TheAssignment %}<tr><td>Total Points:</td><td>{{TheAssignment.total_points}}</td></tr>{% endif %}</table>
	{% if SectionForms %}
	<hr>
	{% for form in SectionForms %}
	{% for field in form.hidden_fields %}{{field}}{% endfor %}
	<div class="sub_form">
	    <div class="title">
		<button type="submit" class="button DeleteButton smallbutton floatright" name="DeleteSection" value="{{forloop.counter}}"  title="Delete This Section">X</button>
		    <a name="section{{form.instance.section_number}}">Section {{form.section_number}}</a>
	    </div>
	    <div class="content">
		<table cellpadding="0" cellspacing="0">
		<tr>
		    <td>{{form.title.label_tag}}</td><td>{{form.title}}<br>{{form.title.help_text}}</td><td>{{form.title.errors}}</td>
		</tr>
		<tr>
		    <td>{{form.total_points.label_tag}}</td><td>{{form.total_points}}<br>{{form.total_points.help_text}}</td><td>{{form.total_points.errors}}</td>
		</tr>
		</table>
	    </div>
	</div>
	{% endfor %}
	{% endif %}
<table>
<tr>
    <td colspan="4" class="Buttons">
	{% if TheAssignment %}<button type="submit" class="button AddButton floatleft" name="NewSection" value="" title="Add A New Section">+</button>{% endif %}
        <button type="submit" class="button SaveButton floatleft" name="Save" value="SaveEdit" title="Save and Continue Editing">Save and Continue</button>
        <button type="submit" class="button SaveButton floatleft" name="Save" value="SaveReturn" title="Save and Return to Gradebook">Save and Return</button>
        <a class="button SaveButton" href="{% course_url management app='grades' %}">Cancel</a>
    </td>
</tr>
</table>
</form>
</div>
